#ifndef ATOMIC_H
#define ATOMIC_H

#include <stdatomic.h>

// 内存序定义
typedef enum {
    RELAXED = memory_order_relaxed,
    RELEASE = memory_order_release,
    ACQUIRE = memory_order_acquire,
    ACQ_REL = memory_order_acq_rel,
    SEQ_CST = memory_order_seq_cst
} memory_order_t;

// 原子操作封装
static inline int atomic_load(const atomic_int *ptr, memory_order_t order) {
    return atomic_load_explicit(ptr, order);
}

static inline void atomic_store(atomic_int *ptr, int val, memory_order_t order) {
    atomic_store_explicit(ptr, val, order);
}

static inline int atomic_exchange(atomic_int *ptr, int val, memory_order_t order) {
    return atomic_exchange_explicit(ptr, val, order);
}

#endif // ATOMIC_H 